package com.danskin.wechat.webapi;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.danskin.wechat.entity.ActivityApply;
import com.danskin.wechat.entity.CarouselInfo;
import com.danskin.wechat.entity.CustActivityApply;
import com.danskin.wechat.entity.CustActivityVote;
import com.danskin.wechat.entity.VipActivity;
import com.danskin.wechat.entity.VipOption;
import com.danskin.wechat.entity.VipVote;
import com.danskin.wechat.model.AccessResponse;
import com.danskin.wechat.service.CarouselInfoService;
import com.danskin.wechat.service.CustActivityApplyService;
import com.danskin.wechat.service.CustActivityVoteService;
import com.danskin.wechat.service.VipActivityService;
import com.danskin.wechat.service.VipOptionService;
import com.danskin.wechat.service.VipVoteService;
import com.danskin.wechat.util.ConvertUtils;
import com.danskin.wechat.util.JsonUtils;
import com.danskin.wechat.util.Page;
import com.danskin.wechat.util.Tools;

@RestController
@RequestMapping("api/activity")
public class ActivityApiController extends BaseApiController {
	
	@Autowired
	private VipActivityService activityService;
	
	
	@Autowired
	private VipVoteService vipVoteService;
	
	@Autowired
	private VipOptionService vipOptionService;
	
	@Autowired
	private CustActivityVoteService custActivityVoteService;
	
	@Autowired
	private CustActivityApplyService  custActivityApplyService;
	
	@Autowired
	private CarouselInfoService  carouselInfoService;
	
	
//----------------------------------------------活动列表-----------------------------------------------------------//	
	/**
	 * 宁聚日列表
	 * @param appId
	 * @param requestParam
	 * @return
	 */
	@RequestMapping(value = "/getNingActivityList/{appId}", produces = "application/json;charset=UTF-8")
	public String getNingActivityList(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		 if (!requestParam.containsKey("pageIndex")) {
			access.setErrorCode("1");
			access.setErrorMsg("pageIndex不能为空");
			return JsonUtils.objectToJson(access);
		}
		 int mpId=0;
		 if(StringUtils.isNotBlank(appId)){
			 mpId = this.getMpId(appId);
		 }
		    List<VipActivity> list=null;
		    String sPageIndex= requestParam.get("pageIndex").toString();
			int pageIndex = ConvertUtils.getInt(sPageIndex);
			int pageSize = 10;
			Page page = new Page();
			page.setCurrentResult(pageIndex);
			page.setShowCount(pageSize);
			if(mpId>0){
				requestParam.put("mpId", mpId);
				requestParam.put("type", 3);
				page.setMap(requestParam);
				list = activityService.findVipActivityList(page);
			}
			List<Map<String,Object>> resList=new ArrayList<>();
			if(list.size()>0){
				for(VipActivity vip:list){
					Map<String,Object> map=new HashMap<>();
					if(null!=vip.getId()){
						map.put("id", vip.getId());
					}
					if(null!=vip.getType()){
						map.put("type", vip.getType());
					}
					if(null!=vip.getHeadPortrait()){
						map.put("activityImg", vip.getHeadPortrait());
					}
					if(null!=vip.getTitle()){
						map.put("activityTitle", vip.getTitle());
					}
					if(null!=vip.getUrl()){
						map.put("url", vip.getUrl());
					}
					if(null!=vip.getState()){
						if("1".equals(vip.getState())){
							map.put("status", "已结束");
						}else{
							if(-1!=Tools.compare_date(vip.getEndTime(), new Date())){
								map.put("status", "进行中");
							}else{
								map.put("status", "已结束");
							}
						}
						
					}
					resList.add(map);
					
				}
				
				access.setErrorCode("0");
				access.setErrorMsg("获取宁聚日列表成功");
				access.setData(resList);
			}else{
				access.setErrorCode("1");
				access.setErrorMsg("获取宁聚日列表失败");
				access.setData("");
			}
		
		
		
		
		return JsonUtils.objectToJson(access);
	}
	/**
	 * 互动活动列表
	 * @param appId
	 * @param requestParam
	 * @return
	 */
	@RequestMapping(value = "/getVoteAndApplyList/{appId}", produces = "application/json;charset=UTF-8")
	public String getVoteAndApplyList(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		if (!requestParam.containsKey("pageIndex")) {
			access.setErrorCode("1");
			access.setErrorMsg("pageIndex不能为空");
			return JsonUtils.objectToJson(access);
		}
		int mpId=0;
		if(StringUtils.isNotBlank(appId)){
			mpId = this.getMpId(appId);
		}
		List<VipActivity> list=null;
		String sPageIndex= requestParam.get("pageIndex").toString();
		int pageIndex = ConvertUtils.getInt(sPageIndex);
		int pageSize = 10;
		Page page = new Page();
		page.setCurrentResult(pageIndex);
		page.setShowCount(pageSize);
		if(mpId>0){
			requestParam.put("mpId", mpId);
			requestParam.put("typeToken", 3);
			requestParam.put("liveTime", new Date());
			page.setMap(requestParam);
			list = activityService.findVipActivityList(page);
		}
		List<Map<String,Object>> resList=new ArrayList<>();
		if(list.size()>0){
			for(VipActivity vip:list){
				Map<String,Object> map=new HashMap<>();
				if(null!=vip.getId()){
					map.put("id", vip.getId());
				}
				if(null!=vip.getType()){
					map.put("type", vip.getType());
				}
				if(null!=vip.getHeadPortrait()){
					map.put("activityImg", vip.getHeadPortrait());
				}
				if(null!=vip.getTitle()){
					map.put("activityTitle", vip.getTitle());
				}
				if(null!=vip.getState()){
					if("1".equals(vip.getState())){
						map.put("status", "已结束");
					}else{
						if(-1!=Tools.compare_date(vip.getEndTime(), new Date())){
							map.put("status", "进行中");
						}else{
							map.put("status", "已结束");
						}
					}
					
				}
				resList.add(map);
				
			}
			
			access.setErrorCode("0");
			access.setErrorMsg("获取活动列表成功");
			access.setData(resList);
		}else{
			access.setErrorCode("1");
			access.setErrorMsg("获取活动列表失败");
			access.setData("");
		}
		return JsonUtils.objectToJson(access);
	}
	/**
	 * 往期活动列表
	 * @param appId
	 * @param requestParam
	 * @return
	 */
	@RequestMapping(value = "/getExpireActivityList/{appId}", produces = "application/json;charset=UTF-8")
	public String getExpireActivityList(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		if (!requestParam.containsKey("pageIndex")) {
			access.setErrorCode("1");
			access.setErrorMsg("pageIndex不能为空");
			return JsonUtils.objectToJson(access);
		}
		int mpId=0;
		if(StringUtils.isNotBlank(appId)){
			mpId = this.getMpId(appId);
		}
		List<VipActivity> list=null;
		String sPageIndex= requestParam.get("pageIndex").toString();
		int pageIndex = ConvertUtils.getInt(sPageIndex);
		int pageSize = 10;
		Page page = new Page();
		page.setCurrentResult(pageIndex);
		page.setShowCount(pageSize);
		if(mpId>0){
			requestParam.put("mpId", mpId);
			requestParam.put("typeToken", 4);
			requestParam.put("expireTime", new  Date());
			page.setMap(requestParam);
			list = activityService.findVipActivityList(page);
		}
		List<Map<String,Object>> resList=new ArrayList<>();
		if(list.size()>0){
			for(VipActivity vip:list){
				Map<String,Object> map=new HashMap<>();
				if(null!=vip.getId()){
					map.put("id", vip.getId());
				}
				if(null!=vip.getType()){
					map.put("type", vip.getType());
				}
				if(null!=vip.getHeadPortrait()){
					map.put("activityImg", vip.getHeadPortrait());
				}
				if(null!=vip.getTitle()){
					map.put("activityTitle", vip.getTitle());
				}
				if(null!=vip.getUrl()){
					map.put("url", vip.getUrl());
				}
				if(null!=vip.getState()){
					if("1".equals(vip.getState())){
						map.put("status", "已结束");
					}else{
						if(1!=Tools.compare_date(vip.getEndTime(),new Date())){
							map.put("status", "已结束");
						}else{
							map.put("status", "进行中");
						}
					}
					
				}
				resList.add(map);
				
			}
			
			access.setErrorCode("0");
			access.setErrorMsg("获取活动列表成功");
			access.setData(resList);
		}else{
			access.setErrorCode("1");
			access.setErrorMsg("获取活动列表失败");
			access.setData("");
		}
		return JsonUtils.objectToJson(access);
	}
	
	
	
	/**
	 * 我的活动列表
	 * @param appId
	 * @param requestParam
	 * @return
	 */
	@RequestMapping(value = "/getMyActivityList/{appId}", produces = "application/json;charset=UTF-8")
	public String getMyActivityList(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		if (!requestParam.containsKey("pageIndex")) {
			access.setErrorCode("1");
			access.setErrorMsg("pageIndex不能为空");
			return JsonUtils.objectToJson(access);
		}else if (!requestParam.containsKey("openId")) {
			access.setErrorCode("1");
			access.setErrorMsg("openId不能为空");
			return JsonUtils.objectToJson(access);
		}else if(StringUtils.isBlank(appId)){
			access.setErrorCode("1");
			access.setErrorMsg("appId不能为空");
			return JsonUtils.objectToJson(access);
		}
		Map<String,Object> map=new HashMap<>();
		
		Map<String,Object> param=new HashMap<>();
		int mpId=0;
		if(StringUtils.isNotBlank(appId)){
			mpId = this.getMpId(appId);
		}
		String sPageIndex= requestParam.get("pageIndex").toString();
		int pageIndex = ConvertUtils.getInt(sPageIndex);
		int pageSize = 10;
		Page page = new Page();
		page.setCurrentResult(pageIndex);
		page.setShowCount(pageSize);
		param.put("openId", requestParam.get("openId"));
		param.put("mpId", mpId);
		page.setMap(param);
		try {
			List<Map<String,Object>> list = custActivityApplyService.listPageMyActivityListByOpenId(page);
			List<Map<String, Object>> count = custActivityApplyService.selectMyActivityListByOpenId(param);
			if(list.size()>0){
				for(Map<String,Object> re:list){
					if(re.containsKey("state")){
						if("1".equals(String.valueOf(re.get("state")))){
							re.put("status", "已结束");
						}else{
							if(-1!=Tools.compare_date(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(String.valueOf(re.get("end_time"))), new Date())){
								re.put("status", "进行中");
							}else{
								re.put("status", "已结束");
							}
						}
						
					}
				}
			}
			map.put("activityNum", count.size());
			map.put("activityList", list);
			access.setErrorCode("0");
			access.setErrorMsg("获取我的活动列表成功");
			access.setData(map);
		} catch (Exception e) {
			access.setErrorCode("1");
			access.setErrorMsg("获取我的活动列表失败");
			access.setData("");
			e.printStackTrace();
		}
	
		
		return JsonUtils.objectToJson(access);
	}
	
	
//---------------------------------------------------------活动列表end-----------------------------------------------//
	
//-----------------------start--------------------------------活动详情--------------------------------------------------//
	
	/**
	 * 查询报名活动详情
	 * @param appId
	 * @param requestParam
	 * @return
	 */
	@RequestMapping(value = "/getApplyActivityDetail/{appId}", produces = "application/json;charset=UTF-8")
	public String getApplyActivityDetail(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		Map<String,Object> map=new HashMap<>();
		try {
			if (!requestParam.containsKey("openId")) {
				access.setErrorCode("1");
				access.setErrorMsg("openId不能为空");
				return JsonUtils.objectToJson(access);
			} else if (!requestParam.containsKey("id")) {
				access.setErrorCode("1");
				access.setErrorMsg("活动id不能为空");
				return JsonUtils.objectToJson(access);
			}
			Map<String,Object> queryParam=new HashMap<>();
			queryParam.put("activityId", requestParam.get("id"));
			Map<String, Integer> applyCountMap = custActivityApplyService.selectActivityCountByActivityId(queryParam);//查询现有活动的参加人数
			if(applyCountMap.containsKey("coun")){
				map.put("activityNumPle",applyCountMap.get("coun"));
			}
			//判断该openId  是否参加过此活动
			int applyCount = custActivityApplyService.selectApplyCountByActivityIdAndOpenId((Integer)requestParam.get("id"), String.valueOf(requestParam.get("openId")));
			if(applyCount>0){
				map.put("state",1);
			}else{
				map.put("state",0);
			}
			
			
			VipActivity vip = activityService.findVipActivitybyId(String.valueOf(requestParam.get("id")));
			if(null!=vip.getHeadPortrait()){
				map.put("activityImg1",vip.getHeadPortrait());
			}
			if(null!=vip.getId()){
				map.put("id",vip.getId());
			}
			if(null!=vip.getTitle()){
				map.put("activityTitle",vip.getTitle());
			}
			if(null!=vip.getJoinNum()){
				map.put("activityMaxCount",vip.getJoinNum());
			}
			if(null!=vip.getAddress()){
				map.put("activitylocation",vip.getAddress());
			}
			if(null!=vip.getBeginTime()){
				map.put("startTime",new SimpleDateFormat("yyyy-MM-dd").format(vip.getBeginTime()));
			}
			if(null!=vip.getEndTime()){
				map.put("endTime",new SimpleDateFormat("yyyy-MM-dd").format(vip.getEndTime()));
			}
			if(null!=vip.getDescription()){
				map.put("activityDetail",vip.getDescription());
			}
			if(null!=vip.getState()){
				if("1".equals(vip.getState())){
					map.put("status", "已结束");
				}else{
					if(-1!=Tools.compare_date(vip.getEndTime(), new Date())){
						map.put("status", "进行中");
					}else{
						map.put("status", "已结束");
					}
				}
				
			}
			access.setErrorCode("0");
			access.setErrorMsg("获取报名活动详情成功");
			access.setData(map);
		} catch (Exception e) {
			access.setErrorCode("1");
			access.setErrorMsg("获取报名活动详情失败");
			access.setData("");
			e.printStackTrace();
		}
		return JsonUtils.objectToJson(access);
	}
	
	/**
	 * 查询投票活动详情
	 * @param appId
	 * @param requestParam
	 * @return
	 */
	@RequestMapping(value = "/getVoteActivityDetail/{appId}", produces = "application/json;charset=UTF-8")
	public String getVoteActivityDetail(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		Map<String,Object> map=new HashMap<>();
		if (!requestParam.containsKey("openId")) {
			access.setErrorCode("1");
			access.setErrorMsg("openId不能为空");
			return JsonUtils.objectToJson(access);
		} else if (!requestParam.containsKey("id")) {
			access.setErrorCode("1");
			access.setErrorMsg("活动id不能为空");
			return JsonUtils.objectToJson(access);
		}
		try {
			List<Integer> optionIdList=new ArrayList<>();
			List<CustActivityVote> list = custActivityVoteService.getCustVoteListByOpenIdAndActivityId(String.valueOf(requestParam.get("openId")),Integer.parseInt(String.valueOf(requestParam.get("id"))));
			if(list.size()>0){
				map.put("state", 1);
				for(CustActivityVote vote:list){
					optionIdList.add(vote.getOptionId());
				}
			}else{
				map.put("state", 0);
			}
			VipActivity vip = activityService.findVipActivitybyId(String.valueOf(requestParam.get("id")));
			if(null!=vip.getId()){
				map.put("id",vip.getId());
			}
			if(null!=vip.getTitle()){
				map.put("title",vip.getTitle());
			}
			if(null!=vip.getEndTime()){
				map.put("endTime",new SimpleDateFormat("yyyy-MM-dd").format(vip.getEndTime()));
			}
			if(null!=vip.getState()){
				if("1".equals(vip.getState())){
					map.put("status", "已结束");
				}else{
					if(-1!=Tools.compare_date(vip.getEndTime(), new Date())){
						map.put("status", "进行中");
					}else{
						map.put("status", "已结束");
					}
				}
				
			}
			Map<String,Object> voteAndOptionParam=new HashMap<>();
			voteAndOptionParam.put("activityId", requestParam.get("id"));
			List<VipVote> voteAndOptionList = vipVoteService.selectVipVoteAndVipOptionByActivityId(voteAndOptionParam);
			if(voteAndOptionList.size()>0){
				for(VipVote vote:voteAndOptionList){
					if(vote.getVipOptionList().size()>0){
						for(VipOption option:vote.getVipOptionList()){
							if(null!=option&&null!=optionIdList){
									if(optionIdList.contains(option.getId())){
										option.setIndexWt("1");
									
								}else{
									option.setIndexWt("0");
								}
							}
						}
					}
				}
				map.put("configList", voteAndOptionList);
			}
			access.setErrorCode("0");
			access.setErrorMsg("获取投票活动详情成功");
			access.setData(map);
		} catch (Exception e) {
			access.setErrorCode("1");
			access.setErrorMsg("获取投票活动详情失败");
			access.setData("");
			e.printStackTrace();
		}
		
		return JsonUtils.objectToJson(access);
	}
	
	
	/**
	 * 查询报名选项
	 */
	
	@RequestMapping(value = "/getApplyActivityOption/{appId}", produces = "application/json;charset=UTF-8")
	public String getApplyActivityOption(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		Map<String,Object> map=new HashMap<>();
		if (!requestParam.containsKey("id")) {
			access.setErrorCode("1");
			access.setErrorMsg("活动id不能为空");
			return JsonUtils.objectToJson(access);
		}
		try {
			List<Map<String,Object>> result=new ArrayList<>();
			List<ActivityApply> list = custActivityApplyService.selectActivityApplyOptionByActivityId(Integer.parseInt(String.valueOf(requestParam.get("id"))));
			if(list.size()>0){
				for(ActivityApply apply:list){
					Map<String,Object> resultMap=new HashMap<>();
					resultMap.put("name", apply.getApplyConfigName());
					result.add(resultMap);
				}
				
			}
			map.put("id", requestParam.get("id"));
			map.put("configList",result);
			access.setErrorCode("0");
			access.setErrorMsg("获取报名选项成功");
			access.setData(map);
		} catch (Exception e) {
			access.setErrorCode("1");
			access.setErrorMsg("获取报名选项失败");
			access.setData("");
			e.printStackTrace();
		}
		return JsonUtils.objectToJson(access);
	}
	/**
	 * 查询活动轮播图queryCarouselInfoImg
	 */
	
	@RequestMapping(value = "/getActivityCarouselList/{appId}", produces = "application/json;charset=UTF-8")
	public String getActivityCarouselList(@PathVariable("appId") String appId){
		AccessResponse<Object> access = new AccessResponse<>();
		if (StringUtils.isBlank(appId)) {
			access.setErrorCode("1");
			access.setErrorMsg("appId不能为空");
			return JsonUtils.objectToJson(access);
		}
		try {
			List<Map<String,Object>> result=new ArrayList<>();
			 List<CarouselInfo> list = carouselInfoService.queryCarouselInfoImg(appId);
			if(list.size()>0){
				for(CarouselInfo carouse:list){
					Map<String,Object> resultMap=new HashMap<>();
					resultMap.put("img", carouse.getImg());
					resultMap.put("url", carouse.getPicUrl());
					result.add(resultMap);
				}
				
			}
			access.setErrorCode("0");
			access.setErrorMsg("获取轮播图成功");
			access.setData(result);
		} catch (Exception e) {
			access.setErrorCode("1");
			access.setErrorMsg("获取轮播图失败");
			access.setData("");
			e.printStackTrace();
		}
		return JsonUtils.objectToJson(access);
	}
	
	
	/**
	 * 保存报名选项
	 */
	@RequestMapping(value = "/saveApplyActivityOption/{appId}", produces = "application/json;charset=UTF-8")
	public String saveApplyActivityOption(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		if (!requestParam.containsKey("id")) {
			access.setErrorCode("1");
			access.setErrorMsg("活动id不能为空");
			return JsonUtils.objectToJson(access);
		}else if (!requestParam.containsKey("openId")) {
			access.setErrorCode("1");
			access.setErrorMsg("openId不能为空");
			return JsonUtils.objectToJson(access);
		}else if (!requestParam.containsKey("data")) {
		access.setErrorCode("1");
		access.setErrorMsg("data不能为空");
		return JsonUtils.objectToJson(access);
	}
		Integer activityId=Integer.parseInt(String.valueOf(requestParam.get("id")));
		String openId=String.valueOf(requestParam.get("openId"));
		
		
		Object dataObject = requestParam.get("data");
		String json = JsonUtils.objectToJson(dataObject);
	    try {
			List<Map> list = JsonUtils.jsonToList(json, Map.class);
			if(list.size()>0){
				for(Map<String,String> map:list){
					CustActivityApply apply=new CustActivityApply();
					if(map.containsKey("name")){
						apply.setApplyCode(map.get("name"));
					}
					if(map.containsKey("value")){
						apply.setApplyValue(map.get("value"));
					}
					apply.setActivityId(activityId);
					apply.setOpenId(openId);
					int i = custActivityApplyService.saveActivityApplySelective(apply);
				}
				
				
			}else{
				access.setErrorCode("1");
				access.setErrorMsg("报名选项不能为空");
				access.setData("");
			}
			access.setErrorCode("0");
			access.setErrorMsg("添加报名活动成功");
			access.setData("");
		} catch (Exception e) {
			access.setErrorCode("1");
			access.setErrorMsg("添加报名活动失败");
			access.setData("");
		}
		return JsonUtils.objectToJson(access);
	}
	/**
	 * 保存活动选项
	 */
	@RequestMapping(value = "/saveVoteActivityOption/{appId}", produces = "application/json;charset=UTF-8")
	public String saveVoteActivityOption(@PathVariable("appId") String appId, @RequestBody Map<String, Object> requestParam){
		AccessResponse<Object> access = new AccessResponse<>();
		if (!requestParam.containsKey("id")) {
			access.setErrorCode("1");
			access.setErrorMsg("活动id不能为空");
			return JsonUtils.objectToJson(access);
		}else if (!requestParam.containsKey("openId")) {
			access.setErrorCode("1");
			access.setErrorMsg("openId不能为空");
			return JsonUtils.objectToJson(access);
		}else if (!requestParam.containsKey("data")) {
			access.setErrorCode("1");
			access.setErrorMsg("data不能为空");
			return JsonUtils.objectToJson(access);
		}
		Integer activityId=Integer.parseInt(String.valueOf(requestParam.get("id")));
		String openId=String.valueOf(requestParam.get("openId"));
		
		
		Object dataObject = requestParam.get("data");
		String json = JsonUtils.objectToJson(dataObject);
		try {
			List<Integer> list = JsonUtils.jsonToList(json, Integer.class);
			if(list.size()>0){
				for(Integer k:list){
					CustActivityVote vote=new CustActivityVote();
					vote.setOpenId(openId);
					vote.setActivityId(activityId);
					vote.setOptionId(k);
					int i = custActivityVoteService.saveCustActivityVoteOption(vote);
					if(i>0){
						VipOption option = vipOptionService.selectByPrimaryKey(k);
						option.setVotedNum(option.getVotedNum()+1);
						vipOptionService.updateByPrimaryKeySelective(option);
					}
					
				
				}
			}else{
				access.setErrorCode("1");
				access.setErrorMsg("投票选项不能为空");
				access.setData("");
			}
			access.setErrorCode("0");
			access.setErrorMsg("添加投票活动成功");
			access.setData("");
		} catch (Exception e) {
			access.setErrorCode("1");
			access.setErrorMsg("添加投票活动失败");
			access.setData("");
		}
		return JsonUtils.objectToJson(access);
	}

	
	
	
}
